import axios from '../api'
interface IContainer {
  value: HTMLElement
}
interface IEcharts {
  [x: string]: any
}
interface IData {
  name: string
  value: number
}
declare const echarts: IEcharts


export default function useTrend(container: IContainer) {
  let charts : any
  let data : IData
  let timeId : number


  const initChart = () => {
    charts = echarts.init(container.value)
    const initOption = {}
    charts.setOption(initOption)
  }

  const getData = async () => {
    // await axios.get('trend')
    // 对data进行赋值
    updateChart()
  }

  const updateChart = () => {
    const updateOption = {

    }
    charts.setOption(updateChart)
  }

  const setIntervalFn = () => {
    timeId = setInterval(() => {

    }, 3000)
  }

  const screenAdapter = () => {
    const adapterOption = {}
    charts.setOption(adapterOption)
    charts.resize()
  }

  const clear = () => {
    clearInterval(timeId)
  }

  return {
    initChart,
    getData,
    setIntervalFn,
    screenAdapter,
    clear
  }
}
